const mysql = require('mysql2/promise');

async function addMoreTestData() {
  const connection = await mysql.createConnection({
    host: '127.0.0.1',
    user: 'root',
    password: '302108jw302',
    database: 'wardrobe_db'
  });

  console.log('开始添加更多测试数据...');

  try {
    // 添加更多衣服数据
    const clothingData = [
      // 更多上装
      [1, 1, '黑色T恤', '黑色', '#000000', 'Nike', 'summer', 'casual', 'available', 129.00, '2024-01-20', '运动休闲T恤', false],
      [1, 1, '红色毛衣', '红色', '#FF0000', 'ZARA', 'winter', 'casual', 'available', 199.00, '2024-02-15', '保暖毛衣', true],
      [1, 1, '蓝色衬衫', '蓝色', '#0000FF', 'H&M', 'all', 'formal', 'available', 159.00, '2024-01-30', '商务衬衫', false],
      [1, 1, '绿色卫衣', '绿色', '#008000', 'Adidas', 'autumn', 'sport', 'available', 299.00, '2024-02-10', '运动卫衣', false],
      
      // 更多下装
      [1, 2, '黑色休闲裤', '黑色', '#000000', 'Uniqlo', 'all', 'casual', 'available', 199.00, '2024-01-25', '百搭休闲裤', false],
      [1, 2, '灰色运动裤', '灰色', '#808080', 'Adidas', 'all', 'sport', 'available', 299.00, '2024-02-20', '运动裤', false],
      [1, 2, '蓝色牛仔裤', '蓝色', '#4169E1', 'Levis', 'all', 'casual', 'available', 399.00, '2024-01-15', '经典牛仔裤', true],
      [1, 2, '白色短裤', '白色', '#FFFFFF', 'ZARA', 'summer', 'casual', 'available', 129.00, '2024-03-01', '夏季短裤', false],
      
      // 外套
      [1, 3, '黑色夹克', '黑色', '#000000', 'ZARA', 'autumn', 'casual', 'available', 399.00, '2024-02-25', '时尚夹克', true],
      [1, 3, '灰色大衣', '灰色', '#808080', 'H&M', 'winter', 'formal', 'available', 599.00, '2024-01-10', '保暖大衣', false],
      [1, 3, '蓝色牛仔外套', '蓝色', '#4169E1', 'Levis', 'spring', 'casual', 'available', 299.00, '2024-03-05', '牛仔外套', false],
      
      // 鞋子
      [1, 4, '白色运动鞋', '白色', '#FFFFFF', 'Nike', 'all', 'sport', 'available', 599.00, '2024-03-01', '经典运动鞋', true],
      [1, 4, '黑色皮鞋', '黑色', '#000000', 'ZARA', 'all', 'formal', 'available', 399.00, '2024-03-05', '正装皮鞋', false],
      [1, 4, '棕色靴子', '棕色', '#8B4513', 'Timberland', 'winter', 'casual', 'available', 799.00, '2024-02-28', '户外靴子', false],
      [1, 4, '红色帆布鞋', '红色', '#FF0000', 'Converse', 'all', 'casual', 'available', 299.00, '2024-03-10', '经典帆布鞋', false],
      
      // 配饰
      [1, 5, '黑色腰带', '黑色', '#000000', 'ZARA', 'all', 'formal', 'available', 99.00, '2024-01-20', '皮质腰带', false],
      [1, 5, '棕色包包', '棕色', '#8B4513', 'Coach', 'all', 'casual', 'available', 1299.00, '2024-02-14', '真皮手提包', true],
      [1, 5, '白色帽子', '白色', '#FFFFFF', 'Nike', 'summer', 'sport', 'available', 159.00, '2024-03-15', '运动帽', false],
      [1, 5, '黑色围巾', '黑色', '#000000', 'H&M', 'winter', 'casual', 'available', 89.00, '2024-01-05', '保暖围巾', false]
    ];

    const sql = `INSERT INTO clothing (user_id, category_id, name, color, color_hex, brand, season, style, status, price, purchase_date, notes, is_favorite, created_at, updated_at) VALUES ?`;
    
    // 为每条记录添加时间戳
    const clothingDataWithTimestamp = clothingData.map(row => [
      ...row,
      new Date(),
      new Date()
    ]);

    await connection.query(sql, [clothingDataWithTimestamp]);
    
    console.log(`成功添加了 ${clothingData.length} 件衣服`);
    
    // 查询总数
    const [rows] = await connection.query('SELECT COUNT(*) as count FROM clothing WHERE user_id = 1');
    console.log(`用户现在总共有 ${rows[0].count} 件衣服`);
    
  } catch (error) {
    console.error('添加数据失败:', error);
  } finally {
    await connection.end();
  }
}

addMoreTestData();
